from selenium import webdriver
import requests

driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(10)
driver.get("https://www.baidu.com")
# 元素.get_attrubute("属性名") 是火兔指定元素括号里对应的属性值
url = driver.find_element("id", "s_lg_img").get_attribute("src")
# .content 是获取二进制数据
datas = requests.get(url).content
# "wb" 是写入二进制文件
with open("baidu.png", "wb") as f:
    f.write(datas)
